<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 01.12.13
 * Time: 18:00
 */
class Tourism_Form_Tours_Create extends Engine_Form
{
  public function init()
  {

    $this
      ->setAttrib('class', 'global_form')
      ->setTitle('Add new tour')
      ->setDescription('You can add new tour.');


    $this->addElement('Text', 'title', array(
      'label' => 'Title',
      'allowEmpty' => false,
      'required' => true,
      'validators' => array(
        array('NotEmpty', true),
        array('StringLength', false, array(1, 64)),
      ),
      'filters' => array(
        'StripTags',
        new Engine_Filter_Censor(),
      ),
    ));

    $this->addElement('TinyMce', 'description', array(
      'label' => 'Body',
      'required' => true,
      'editorOptions' => array(
        'bbcode' => true,
        'html' => true,
      ),
      'allowEmpty' => false,
    ));

    $this->addElement('Text', 'price', array(
      'label' => 'Price',
      'allowEmpty' => false,
      'required' => true,
      'validators' => array(
        array('NotEmpty', true),
        array('StringLength', false, array(1, 10)),
      ),
      'filters' => array(
        'StripTags',
        new Engine_Filter_Censor(),
      ),
    ));

    $this->addElement('Select', 'type', array(
      'label' => 'Tour Type',
      'multiOptions' => array('package' => 'Package', 'daily' => 'Daily'),
      'required' => true,
      'allowEmpty' => false,
    ));
    
    $this->addElement('File', 'photo', array(
      'label' => 'Photo',
      'destination' => APPLICATION_PATH.'/public/temporary/',
      'multiFile' => 1,
      'validators' => array(
        array('Count', false, 1),
        array('Extension', false, 'jpg,jpeg,png,gif'),
      )
    ));

    // Buttons
    $this->addElement('Button', 'submit', array(
      'label' => 'Save Changes',
      'type' => 'submit',
      'ignore' => true,
      'decorators' => array('ViewHelper')
    ));

    $this->addElement('Cancel', 'cancel', array(
      'label' => 'cancel',
      'link' => true,
      'prependText' => ' or ',
      'onclick' => 'parent.Smoothbox.close();',
      'decorators' => array(
        'ViewHelper'
      )
    ));
  }
}